package BinarySearchTree;

import com.sun.source.tree.Tree;

import javax.swing.tree.TreeNode;

public class BinarysearchTree {

static class TreeNpde{
    int val;
    TreeNpde left;
    TreeNpde right;

    public TreeNpde(int val) {
        this.val = val;
    }
}

public TreeNpde root;

public void inserrt(int val){
if(root==null){
    root=new TreeNpde(val);
    return;
}
TreeNpde cur=root;
TreeNpde parent=cur;
    TreeNpde node=new TreeNpde(val);

while(cur!=null){
    if(val> cur.val){
        parent=cur;
        cur=cur.right;
    } else{
        parent=cur;
        cur=cur.left;
    }
}
if(parent.val>val){
    parent.left=node;
}else {
    parent.right=node;
}



}

public TreeNpde search(int val){
    TreeNpde cur=root;
    while(cur!=null){
        if(val== cur.val){
            return cur;
        }else if(val< cur.val){
            cur=cur.left;
        }else {
            cur=cur.right;
        }
    }
    return null;
}


public void drop(int val){



}

}
